#Boa:Dialog:Dialog1

import wx
import consultasBD
import MySQLdb

def create(parent):
    return Dialog1(parent)

[wxID_DIALOG1, wxID_DIALOG1INUSER, 
] = [wx.NewId() for _init_ctrls in range(2)]

class Dialog1(wx.Dialog):
    def _init_ctrls(self, prnt):
        # generated method, don't edit
        wx.Dialog.__init__(self, id=wxID_DIALOG1, name='', parent=prnt,
              pos=wx.Point(575, 291), size=wx.Size(400, 250),
              style=wx.DEFAULT_DIALOG_STYLE, title='Dialog1')
        self.SetClientSize(wx.Size(384, 214))

        self.inuser = wx.TextCtrl(id=wxID_DIALOG1INUSER, name='inuser',
              parent=self, pos=wx.Point(72, 40), size=wx.Size(100, 21), style=0,
              value='')

    def __init__(self, parent):
        self._init_ctrls(parent)
        self.servidor()
        
    def servidor(self):
        user = executaSQL2(self,"*","usuarios","1")
        for u in user:
            print "remoto"+str(u[1])
            self.inuser.ChangeValue(str(u[1]))

def executaSQL2(self,camposSQL,tablaSQL,condicion):
        db=MySQLdb.connect(host="mysql.diegolevental.com.ar",user="diego",passwd="asd1234",db="erpsussan")
        c=db.cursor()
        print 'Select %s from %s where %s' % (camposSQL,tablaSQL,condicion)
        c.execute("""Select %s from %s where %s""" % (camposSQL,tablaSQL,condicion))
        return c.fetchall()
